import { request } from './request'
import qs from 'qs'


/*================== 互动发帖 ==================*/
//互动发帖 数据列表
export function getForumByPage(obj) {
    return request({
        url: 'forum/listForum',
        method: 'post',
        data: qs.stringify(obj)
    })
}

//互动发帖 帖子图片列表
export function previewForum(obj) {
    return request({
        url: 'forum/listForumImg',
        method: 'post',
        data: qs.stringify(obj)
    })
}

//帖子修改点击数
export function updateForumPraiseNum(obj) {
    return request({
        url: 'forum/updateForumPriseNum',
        method: 'post',
        data: qs.stringify(obj)
    })
}


//帖子  上线 下线
export function examForums(obj) {
    return request({
        url: 'forum/updateForumStatus',
        method: 'post',
        data: qs.stringify(obj)
    })
}

//帖子置顶/轮播/取消
export function topForums(obj) {
    return request({
        url: 'forum/updateForumTop',
        method: 'post',
        data: qs.stringify(obj)
    })
}

//发帖
export function addForumContent(obj) {
    return request({
        url: 'forum/addForum',
        headers: { 'content-type': 'multipart/form-data' },
        method: 'post',
        data: obj
    })
}



//url 关联
export function getLinkCon(val, obj) {
    if (val == "detail.html") {
        return request({
            url: 'product/listShopProduct',
            method: 'post',
            data: qs.stringify(obj)
        })
    } else if (val == "forum_knowledge.html") {
        return request({
            url: 'forum/getTopicNames',
            method: 'post',
            data: qs.stringify(obj)

        })
    } else if (val == "expert_info.html") {
        var nObj = {
            shopId: 0,
            flag: 1
        }
        return request({
            url: 'doctor/getDoctors',
            method: 'post',
            data: qs.stringify(nObj)

        })
    } else if (val == "forum_detail.html") {
        return request({
            url: 'forum/getForumNames',
            method: 'post',
            data: qs.stringify(obj)
        })
    } else if (val == "groupBuy.html" || val == "secondKill.html") {
        return request({
            url: 'group/getGroupName',
            method: 'post',
            data: qs.stringify(obj)
        })
    } else {
        this.$message.error("预期之外的错误")
    }
}



// 删除帖子
export function deleteForum(obj) {
    return request({
        url: 'forum/deletetiezi',
        method: 'post',
        data: qs.stringify(obj)
    })
}

// 更新图片链接
export function updateForumImg(obj) {
    return request({
        url: 'forum/updateForumImg',
        method: 'post',
        data: qs.stringify(obj)
    })
}